
#include "stdafx.h"

#include "../../loader.h"
using namespace dlguif;

#include <iostream>
using std::cout;
using std::cerr;
using std::endl;


Loader loader;
void* form = NULL;
void* prbar = NULL;


void CALLBACK OnGuiEvent(void* user_context, const callback_info* ci)
{
	static int count = 0;
	count ++;

	Loader* ploader = (Loader*)user_context;

	if(ci->eventType == EVENT_TYPE_FORM_CLOSE)
	{
		ploader->PostExit(0);
	}

	static int val = count;
	val++;
	if(val > 100) val = 100;
	loader.SetProgressBarPosition(prbar, val);
	if(val >=100) val  = 0;


}


int _tmain(int argc, _TCHAR* argv[])
{
	//Loader loader; //(L"j:/dlguif/dlguif/delphi_dll_project/dlguif.dll");
	loader.SetGuiEventCallBack(OnGuiEvent,  (void*)&loader );

	form = loader.CreateForm("caption", "myform", 10, 10, 300, 200);

	prbar = loader.CreateProgressBar(form, form, &Loader::MakeRectangle(20, 20, 230, 20) );
	loader.SetProgressBarPosition(prbar, 50);

	loader.ShowForm(form);


	while( loader.ProcessMessages() )
	{
		Sleep(1);
	}

	return 0;
}